package com.mstore.dao;

import java.util.List;

import com.mstore.pojo.BAnnouncement;

public class BAnnouncementDao extends SuperDao {

	/**
	 * 查询所有积分公告
	 */
	public List<Object> selectAll(BAnnouncement bAnnouncement) {
		String hql = "from  BAnnouncement where  eaId = ?";
		Object[] values = new Object[] { bAnnouncement.getEaId() };
		return super.getObject(hql, values);
	}

	/**
	 * 保存
	 */
	public void saveBAnnouncement(BAnnouncement bAnnouncement) {
		super.save(bAnnouncement);
	}

	/**
	 * 删除
	 */
	public void deleteBAnnouncement(BAnnouncement bAnnouncement) {
		super.delete(bAnnouncement);
	}

	/**
	 * 更新
	 */
	public void updatebAnnouncement(BAnnouncement bAnnouncement) {
		
		StringBuilder sb=new StringBuilder();
		sb.append("update b_announcement set ea_id='");
		sb.append(bAnnouncement.getEaId());
		sb.append("',announcement ='");
		sb.append(bAnnouncement.getAnnouncement());
		sb.append("', create_time = '");
		sb.append(bAnnouncement.getCreateTime());
		sb.append("', title = '");
		sb.append(bAnnouncement.getTitle());
		sb.append("'  where id = ");
		sb.append(bAnnouncement.getId());
		
		super.executeUpdate(sb.toString());
	}

	/**
	 * 根据id查找单个
	 */
	public Object selectById(BAnnouncement bAnnouncement) {
		String hql = "FROM BAnnouncement WHERE id = ?";
		Object[] values = new Object[] { bAnnouncement.getId() };
		List<Object> list = super.getObject(hql, values);
		if (list.size() != 0) {
			return list.get(0);
		}
		return null;
	}
}
